﻿using System;
using System.Collections.Generic;
using System.Linq;
using YJKSparseDisOfRoom.ModelLayer;

namespace YJKSparseDisOfRoom.ControlLayer
{
	internal class RoomBFSGeter
	{
		internal List<RoomNodePacker> GetPrepareCalculeNodes(List<RoomNodePacker> intputRoots)
		{
			return this.FindRoomByBFS(intputRoots);
		}

		private List<RoomNodePacker> FindRoomByBFS(List<RoomNodePacker> inputRoots)
		{
			List<RoomNodePacker> list = new List<RoomNodePacker>();
			foreach (RoomNodePacker roomNodePacker in inputRoots)
			{
				foreach (RoomNodePacker roomNodePacker2 in roomNodePacker.GetNearRoomNodePacker())
				{
					if (roomNodePacker2.CalculateConditionEnum == NodeConditionEnum.NoneCalculate)
					{
						roomNodePacker2.CalculateConditionEnum = NodeConditionEnum.PrepareCalculate;
						list.Add(roomNodePacker2);
					}
				}
			}
			list = list.Distinct<RoomNodePacker>().ToList<RoomNodePacker>();
			return list;
		}
	}
}
